home *** CD-ROM | disk | FTP | other *** search
- function worldClicked(xm, ym, keyCode)
- {
- var temp = iso.mapToIsoWorld(xm,ym);
- var xm = temp[0];
- var zm = temp[1];
- if(!world.char.moving && xm >= 0 && xm <= world.width && zm >= world.length && zm <= 0)
- {
- var x = world.char.x;
- var z = world.char.z;
- world.char.startx = x;
- world.char.startz = z;
- world.char.endx = xm;
- world.char.endz = zm;
- world.char.movKey = keyCode;
- var angleSpan = 45;
- var angle = Math.atan2(zm - z,xm - x);
- var realAngle = angle * 180 / 3.141592653589793;
- realAngle += angleSpan / 2;
- if(realAngle < 0)
- {
- realAngle += 360;
- }
- var frame = Math.ceil(realAngle / angleSpan);
- world.char.clip.gotoAndStop("walk" + frame);
- world.char.frame = frame;
- world.char.moving = true;
- var cosAngle = Math.cos(angle);
- var sinAngle = Math.sin(angle);
- world.char.xmov = world.char.speed * cosAngle;
- world.char.zmov = world.char.speed * sinAngle;
- world.char.feelerx = world.char.feeler * cosAngle;
- world.char.feelerz = world.char.feeler * sinAngle;
- }
- }
- function fnCaptureKeys()
- {
- if(!world.char.teleporting)
- {
- var newx;
- var newy;
- if(Key.isDown(102) or Key.isDown(69) or Key.isDown(79) or Key.isDown(39))
- {
- newx = world.char.clip._x + world.cellWidth / 2;
- newy = world.char.clip._y - (world.cellWidth / 2 - world.angleOffset);
- gameMC.worldClicked(newx,newy,Key.getCode());
- }
- else if(Key.isDown(100) or Key.isDown(85) or Key.isDown(81) or Key.isDown(38))
- {
- newx = world.char.clip._x - world.cellWidth / 2;
- newy = world.char.clip._y - (world.cellWidth / 2 - world.angleOffset);
- gameMC.worldClicked(newx,newy,Key.getCode());
- }
- else if(Key.isDown(99) or Key.isDown(76) or Key.isDown(68) or Key.isDown(40))
- {
- newx = world.char.clip._x + world.cellWidth / 2;
- newy = world.char.clip._y + (world.cellWidth / 2 - world.angleOffset);
- gameMC.worldClicked(newx,newy,Key.getCode());
- }
- else if(Key.isDown(97) or Key.isDown(65) or Key.isDown(74) or Key.isDown(37))
- {
- newx = world.char.clip._x - world.cellWidth / 2;
- newy = world.char.clip._y + (world.cellWidth / 2 - world.angleOffset);
- gameMC.worldClicked(newx,newy,Key.getCode());
- }
- }
- }
-